package com.imooc.security.core.validate.code.image;

import java.awt.image.BufferedImage;
import java.time.LocalDateTime;

import com.imooc.security.core.validate.code.ValidateCode;
// 4.10.4 改成继承方式
public class ImageCode extends ValidateCode {
	
	// 5.10.6 解决BufferdImage不可序列化问题
	private BufferedImage image;
	
	public ImageCode(BufferedImage image, String code, LocalDateTime expireTime) {
		super(code, expireTime);
		this.image = image;
	}
	
	public ImageCode(BufferedImage image, String code, int expireIn) {
		super(code, expireIn);
		this.image = image;
	}

	public BufferedImage getImage() {
		return image;
	}

	public void setImage(BufferedImage image) {
		this.image = image;
	}
}

/**
 * 4.7.1 创建验证码类
 * 
 * @author qilongfei
 *
 */
/*public class ImageCode {
	private BufferedImage image;
	private String code;
	private LocalDateTime expireTime;

	*//**
	 * 4.7.2 构造方法，过期时间点
	 * @param image
	 * @param code
	 * @param expireIn
	 *//*
	public ImageCode(BufferedImage image, String code, int expireIn) {
		this.image = image;
		this.code = code;
		this.expireTime = LocalDateTime.now().plusSeconds(expireIn);
	}
	
	public ImageCode(BufferedImage image, String code, LocalDateTime expireTime) {
		this.image = image;
		this.code = code;
		this.expireTime = expireTime;
	}

	public BufferedImage getImage() {
		return image;
	}

	public void setImage(BufferedImage image) {
		this.image = image;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public LocalDateTime getExpireTime() {
		return expireTime;
	}

	public void setExpireTime(LocalDateTime expireTime) {
		this.expireTime = expireTime;
	}
	
	*//**
	 * 4.7.13 判断验证码是否过期
	 * @return
	 *//*
	public boolean isExpired(){
		return LocalDateTime.now().isAfter(expireTime);
	}
}*/
